package com.dzzw.Servlet.UMailBoxServlet;

import com.dzzw.Dao.UMailBoxDao;
import com.dzzw.Model.UMailBox;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/View/UMailBoxAddServlet")
public class UMailBoxAddServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    UMailBoxDao uMailBoxDao = new UMailBoxDao();
    public UMailBoxAddServlet(){
        super();
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        int user_id = Integer.parseInt(request.getParameter("user_id"));
        String user_title = request.getParameter("user_title");
        String user_content = request.getParameter("user_content");
        UMailBox uMailBox = new UMailBox();
        uMailBox.setUser_id(user_id);
        uMailBox.setUser_title(user_title);
        uMailBox.setUser_content(user_content);
        uMailBoxDao.UMailBoxAdd(uMailBox);
        response.sendRedirect("/View/User.jsp");
    }
}
